package com.gosophia.conference.action.summary;

import java.util.List;

import net.sf.json.JSONArray;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.conferenceManagement.summary.dto.SummaryJobDataDTO;
import com.gosophia.conferenceManagement.summary.ws.SummaryWebService;
import com.gosophia.oa.action.JudgeCurrentUndertaker;
import com.gosophia.userManagement.dto.UserInfoDTO;
import com.gosophia.userManagement.ws.UserManagementWebService;

/**
 * 跳转到发送邮件页面
 * @author mayue
 *
 */
@Scope("prototype")
@Controller("ToSendSummaryPageAction")
public class ToSendSummaryPageAction extends BaseSupportAction {
    
    private static final long serialVersionUID = 1L;

    @Autowired
    UserManagementWebService userManagementWebService;
    
    @Autowired
    private SummaryWebService summaryWebService;
    @Autowired
    private JudgeCurrentUndertaker judgeCurrentUndertaker;
    
    private SummaryJobDataDTO summaryJobDataDTO;
    
    private String recipientListString ;

    private String onlinePath;
    
    private String onlineVersion;
    
    private String onlineIsEdit = "0,0";
    
    private Long jobId;
    @Override
    public String _execute() throws Exception {
        
        //判断当前用户和job承办人是否匹配,如果不匹配转到异常页面
        judgeCurrentUndertaker.judgeOperationAuthority(jobId);
        
        //邮件接收人列表
        List<UserInfoDTO> recipientList = userManagementWebService.findAllUserInfo();
        if(recipientList!=null){
            recipientListString = JSONArray.fromObject(recipientList).toString().replace("\"", "\\\"");
        }
        summaryJobDataDTO = summaryWebService.findPreSummaryJobDataByJobDataId(jobId);
        
        //获取在线文档信息
        if(summaryJobDataDTO!=null && summaryJobDataDTO.getOnlineDocumentDTO()!=null){
            onlinePath = summaryJobDataDTO.getOnlineDocumentDTO().getDocumentPath();
            onlineVersion= summaryJobDataDTO.getOnlineDocumentDTO().getDocumentVersion();
        }
        
        return SUCCESS;
    }
    public SummaryJobDataDTO getSummaryJobDataDTO() {
        return summaryJobDataDTO;
    }
    public void setSummaryJobDataDTO(SummaryJobDataDTO summaryJobDataDTO) {
        this.summaryJobDataDTO = summaryJobDataDTO;
    }
    public String getRecipientListString() {
        return recipientListString;
    }
    public void setRecipientListString(String recipientListString) {
        this.recipientListString = recipientListString;
    }
    public String getOnlinePath() {
        return onlinePath;
    }
    public void setOnlinePath(String onlinePath) {
        this.onlinePath = onlinePath;
    }
    public String getOnlineVersion() {
        return onlineVersion;
    }
    public void setOnlineVersion(String onlineVersion) {
        this.onlineVersion = onlineVersion;
    }
    public Long getJobId() {
        return jobId;
    }
    public void setJobId(Long jobId) {
        this.jobId = jobId;
    }
    public String getOnlineIsEdit() {
        return onlineIsEdit;
    }
    public void setOnlineIsEdit(String onlineIsEdit) {
        this.onlineIsEdit = onlineIsEdit;
    }
    
}
